package com.etc.controller;

import com.etc.entity.Author;
import com.etc.service.AuthorService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthorController {

    private Logger logger = LogManager.getLogger(getClass());

    @Autowired
    private AuthorService service;

    @GetMapping("author/{authorid}")
    public Author getAuthorById(@PathVariable("authorid") int authoid){
        logger.info("getAuthorById "+ authoid);
        return service.getById(authoid);
    }
}
